package com.bw.day2task.mvp.model;

import com.bw.day2task.api.Api;
import com.bw.day2task.bean.BeanPhone;
import com.bw.day2task.bean.BeanUser;
import com.bw.day2task.bean.BeanUserlog;
import com.bw.day2task.bean.BeanVideo;
import com.bw.day2task.mvp.content.LogContent;
import com.bw.day2task.http.HttpRetrofit;
import com.bw.library.mvp.model.BaseModel;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class LogModel extends BaseModel implements LogContent.Model {

    @Override
    public void requestLog(String name, String pass, Observer<BeanUserlog> observer) {
        HttpRetrofit.getHttpRetrofit().getRetrofit()
                .create(Api.class)
                .log("register?name="+name+"&password="+pass)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    @Override
    public void requestreg(String name, String pass, Observer<BeanUser> observer) {
        HttpRetrofit.getHttpRetrofit().getRetrofit()
                .create(Api.class)
                .reg("login?name="+name+"&password="+pass)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    @Override
    public void requesvideo(Observer<BeanPhone> observer) {
        HttpRetrofit.getHttpRetrofit().getRetrofit()
                .create(Api.class)
                .video("13151830132")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    @Override
    public void requesvideo2(Observer<BeanVideo> observer) {
        HttpRetrofit.getHttpRetrofit().getRetrofit()
                .create(Api.class)
                .video2()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }
}
